#ifndef THINGPLE_TCP_SERVER_HANDLER_H
#define THINGPLE_TCP_SERVER_HANDLER_H

#include <iostream>
#include <cstdio>
#include <AlienGenNetwork.h>
#include <AlienGenSerialLine.h>


class ThingpleTcpServerHandler : public AlienGenNetHandler, public AlienGenIO
{
public:
    ThingpleTcpServerHandler(void);
    ThingpleTcpServerHandler(int port, const QString &serialPort);

    void startServer();
    void left(char* dst, char* src, int n);
    int  charFlow(char ant);
    void assignPhysicalAnt(char i);
protected:
    void start(void);
    void onConnect(int fd);
    void stop(void);

private:
    bool _stop;
    AlienGenTcpServer _server;
    QString _serialPort;
    int SerialFd;
    char cancel_cde[8] = {0x40,0x03,0x00,0x00,0x00,0x00,0x00,0x00};//cancel
    char cancel_response[8] = {0x40,0x03,0xBF,0xFC,0xBF,0xFC,0xBF,0xFC};
    char is_active[8] = {0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00};// is active
    char select_logical_ant[8] = {0x01,0x00,0x01,0x07,0x00,0x00,0x00,0x00};//select logical antenna;
    char enable_logical_ant[8] = {0x01,0x00,0x02,0x07,0x01,0x00,0x00,0x00};//enable logical antenna
    char assign_physical_ant0[8] = {0x01,0x00,0x04,0x07,0x00,0x00,0x00,0x00};//assign physical antenna
    char Impinj_Extensions_TagFocus[8] = {0x01,0x00,0x03,0x02,0x10,0x00,0x00,0x00};// HST_IMPINJ_EXTENSIONS TagFocus
    char Impinj_Extensions_FastID[8] = {0x01,0x00,0x03,0x02,0x30,0x00,0x00,0x00};// HST_IMPINJ_EXTENSIONS FastID
    char Query_CFG_cde[8] = {0x01,0x00,0x00,0x09,0xA0,0x00,0x00,0x00};// HST_QUERY_CFG_CDE
    char INV_PARM_2_CDE[8] = {0x01,0x00,0x05,0x09,0x00,0x00,0x00,0x00};//HST_INV_PARM_2_CDE
    char start_Inv_cde[8] = {0x01,0x00,0x00,0xF0,0x0F,0x00,0x00,0x00}; //START_INV_CDE

};

#endif // THINGPLE_TCP_SERVER_HANDLER_H
